package com.geospatial.algorithm.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.*;

@Data
@Component
@ConfigurationProperties(prefix = "index")
public class ApplicationConfig {
    public Map geohashConfig;   //与yml文件配置名称相同


    public Map getGeohashConfig() {
        return geohashConfig;
    }

    public void setGeohashConfig(Map geohashConfig) {
        Map<Integer,Integer> map = (Map<Integer, Integer>) geohashConfig.get("BITS");
        List<Integer> list = new ArrayList<>();
        Iterator<Map.Entry<Integer, Integer>> entries = map.entrySet().iterator();
        while (entries.hasNext()) {
            Map.Entry<Integer, Integer> entry = entries.next();
            list.add(Integer.parseInt(entry.getValue().toString()));
        }

        geohashConfig.put("BITS",list);
        this.geohashConfig = geohashConfig;
    }
}
